home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.1 KB | 199 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMemMgr.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFound.hpp"
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- #ifndef FWODEXCE_H
- #include "FWODExce.h"
- #endif
-
- #ifndef FWMEMHLP_H
- #include "FWMemHlp.h"
- #endif
-
- #ifndef FWNEW_H
- #include "FWNew.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__OSUTILS__)
- #include <OSUtils.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__MEMORY__)
- #include <Memory.h>
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWS)
- #include <Windows.h>
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWSX)
- #include <WindowsX.h>
- #endif
-
- #if !defined(FW_qUsePlatformAlloc) && !defined(FW_qUseCRuntimeAlloc)
-
- #ifdef FW_BUILD_WIN
- #include <MMStubs.h>
- #endif
-
- #ifdef FW_BUILD_MAC
- #include <MemMgr.h>
- #endif
-
- #endif
-
- #include <string.h>
-
- #if defined(__SC__) && defined(FW_BUILD_WIN)
-
- #if !defined(__LIMITS_H)
- #include <limits.h>
- #endif
-
- #if !defined(__HUGEPTR_H) && defined(FW_BUILD_WIN16)
- #include <hugeptr.h>
- #endif
-
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWMemory
- #endif
-
- //========================================================================================
- // CLASS FW_CMemoryManager
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryManager::DefaultNewHandler
- //----------------------------------------------------------------------------------------
-
- void FW_CMemoryManager::DefaultNewHandler()
- {
- FW_Failure(FW_xMemoryExhausted);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryManager::AllocateBlock - Allocate a non-relocatable block of fMemory.
- //----------------------------------------------------------------------------------------
- void* FW_CMemoryManager::AllocateBlock(unsigned long bytesRequested)
- {
- void* aBlock = FW_PrivMemoryManager_AllocateBlock(bytesRequested);
-
- if (aBlock == 0)
- FW_Failure(FW_xMemoryExhausted);
-
- return aBlock;
- }
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWMemMgr2
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryManager::ResizeBlock - Resize a non-relocatable block of fMemory. The
- // block may be moved to a new location if necessary.
- //----------------------------------------------------------------------------------------
- void *FW_CMemoryManager::ResizeBlock(void *aBlock, unsigned long bytesRequested)
- {
- void *newBlock = FW_PrivMemoryManager_ResizeBlock(aBlock, bytesRequested);
-
- if (newBlock == 0)
- FW_Failure(FW_xMemoryExhausted);
-
- return newBlock;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryManager::AllocateSystemHandle -
- //----------------------------------------------------------------------------------------
- FW_PlatformHandle FW_CMemoryManager::AllocateSystemHandle(unsigned long bytesNeeded)
- {
- FW_PlatformHandle aSystemHandle = FW_PrivMemoryManager_AllocateSystemHandle(bytesNeeded);
-
- if (aSystemHandle == 0)
- FW_Failure(FW_xMemoryExhausted);
-
- return aSystemHandle;
- }
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWMemMgr3
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryManager::ResizeSystemHandle -
- //----------------------------------------------------------------------------------------
- FW_PlatformHandle FW_CMemoryManager::ResizeSystemHandle(FW_PlatformHandle aHandle,
- unsigned long bytesNeeded)
- {
- FW_ASSERT(aHandle != 0);
-
- FW_PlatformHandle newHandle = FW_PrivMemoryManager_ResizeSystemHandle(aHandle, bytesNeeded);
-
- if (newHandle == 0)
- FW_Failure(FW_xMemoryExhausted);
-
- return newHandle;
- }
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWMemMgr4
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryManager::LockSystemHandle -
- //----------------------------------------------------------------------------------------
- void * FW_CMemoryManager::LockSystemHandle(FW_PlatformHandle aHandle)
- {
- FW_ASSERT(aHandle != 0);
-
- void* memory = FW_PrivMemoryManager_LockSystemHandle(aHandle);
-
- if (memory == NULL)
- FW_Failure(FW_xMemoryExhausted);
-
- return memory;
- }
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWMemMgr6
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryManager::CopySystemHandle -
- //----------------------------------------------------------------------------------------
- FW_PlatformHandle FW_CMemoryManager::CopySystemHandle(FW_PlatformHandle aHandle)
- {
- FW_PlatformHandle newHandle = FW_PrivMemoryManager_CopySystemHandle(aHandle);
-
- if (newHandle == 0)
- FW_Failure(FW_xMemoryExhausted);
-
- return newHandle;
- }
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWMemMgr7
- #endif
-
-